using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Afrs.Draco.Prms.Client.Proxy;
using Afrs.Prms.DataObject;

namespace 
{
  /// <summary>
  /// TGovdep Test Class
  /// </summary>
  [TestClass]
  public class TestTGovdep
  {
    #region Class Variables
    private CdoPrms<DOTGovdep>		m_TGovdep;
    private CdoPrmsList<DOTGovdep>	m_AllTGovdep;
    #endregion

    #region Class Constructors & Destructors
    /// <summary>
    /// Constructs the test
    /// </summary>
    public TestTGovdep()
    {
      // Create the data objects
      this.m_TGovdep	= new CdoPrms<DOTGovdep>();
      this.m_AllTGovdep	= new CdoPrmsList<DOTGovdep>();
    }
    #endregion

    #region Class Methods
    /// <summary>
    /// Retrieves all TGovdep data objects
    /// </summary>
    [TestMethod]
    public void TGovdepRetrieveAll()
    {
      // Set up the data object for list retrieval
      this.m_AllTGovdep.DataObject = new DOTGovdep();
      this.m_AllTGovdep.ListAction = AfrsDOListAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_AllTGovdep.PerformAction())
      {
        // Assert the errors
        if (this.m_AllTGovdep.Errors.Count > 0) { Assert.Fail(this.m_AllTGovdep.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Create a new TGovdep
    /// </summary>
    [TestMethod]
    public void TGovdepCreate()
    {
      // Set up the data object for creation
      this.m_TGovdep.DataObject.Action = AfrsDataObjectAction.Create;

      // Perform the action and determine the success
      if (!this.m_TGovdep.PerformAction())
      {
        // Assert the errors
        if (this.m_TGovdep.Errors.Count > 0) { Assert.Fail(this.m_TGovdep.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Retrieves a specific TGovdep
    /// </summary>
    [TestMethod]
    public void TGovdepRetrieve()
    {
      // Determine whether the data object needs to be specified
      if (this.m_TGovdep.DataObject.Id == 0)
      {
        // Specify the data object to retrieve
        this.m_TGovdep.DataObject.govdep = "Test govdep";
      }

      // Set up the data object action for retrieval
      this.m_TGovdep.DataObject.Action = AfrsDataObjectAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_TGovdep.PerformAction())
      {
        // Assert the errors
        if (this.m_TGovdep.Errors.Count > 0) { Assert.Fail(this.m_TGovdep.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }
    #endregion
  }
}
